<template>
  <div class="container content-width-min">
    <div class="active-container" ref="extendEle">
      <div class="content">
        <div class="title">{{ topicName.name }}</div>
        <div class="context">
          <span ref="remarkEle">{{ topicName.remark }}</span>
        </div>
        <div v-show="contextShow">
          <div v-show="showEle" class="active-extend-toggle" @click="unfold">展开</div>
          <div v-show="!showEle" class="active-extend-toggle" @click="fold">收起</div>
        </div>
      </div>
    </div>
    <!-- 类型 -->
    <div class="filter-container activity_zone">
      <div class="filter-content-container">
        <div class="filter-row el-row clearfix">
          <div class="filter-label">类型：</div>
          <div class="filter-content">
            <div @click="type = 1" :class="type == 1 ? 'select-item active' : 'select-item'">
              全部
            </div>
            <div @click="type = 2" :class="type == 2 ? 'select-item active' : 'select-item'">
              视频课
            </div>
            <div @click="type = 3" :class="type == 3 ? 'select-item active' : 'select-item'">
              线下课
            </div>
            <div @click="type = 4" :class="type == 4 ? 'select-item active' : 'select-item'">
              直播课
            </div>
          </div>
        </div>
      </div>
    </div>
    <!--导航 -->
    <Order></Order>
    <!--视频-->
    <VideoCard :videoData="videoList"></VideoCard>
  </div>
</template>

<script lang="ts">
import { defineComponent } from 'vue';
import router from '@/router';
import { ElLoading, ElMessage } from 'element-plus';

export default defineComponent({
  name: 'Special',
});
</script>

<script setup lang="ts">
import Order from '../components/order.vue';
import { onMounted, ref, nextTick } from 'vue';
import { type ContentType, reqTopicList } from '@/api/class';
import useClassStore from '@/store/class';
import { storeToRefs } from 'pinia';
onMounted(async () => {
  try {
    ElLoading.service({ fullscreen: true });

    await getTopicList();
    //获取视频列表
    await classStore.getVideoList();
    ElLoading.service({ fullscreen: true }).close();
  } catch (err) {
    ElLoading.service({ fullscreen: true }).close();
    ElMessage.error(err);
  }
});
//获取点击数据

const classStore = useClassStore();
const { videoList } = storeToRefs(classStore);

const type = ref(1);
//获取主题列表ReqTopicList
const topicList = ref<ContentType[]>();
const pageSize = ref(16);
const topicName = ref({
  name: '',
  remark: '',
});
//显示展开收起按钮

const remarkEle = ref();
const contextShow = ref(false);
const getTopicList = async () => {
  const res = await reqTopicList(pageSize.value);
  topicList.value = res.content;
  const a = topicList.value?.filter((item) => item.id === router.currentRoute.value.query.id);

  topicName.value.name = a[0]?.name || '';
  topicName.value.remark = a[0]?.remark || '';
  await nextTick();
  if (remarkEle.value.offsetHeight > remarkEle.value.parentNode.offsetHeight) {
    contextShow.value = true;
  }
};
//点击展开
const extendEle = ref();
const showEle = ref(true);
const unfold = () => {
  extendEle.value.className = 'active-container extend';
  showEle.value = false;
};
//收起
const fold = () => {
  extendEle.value.className = 'active-container';
  showEle.value = true;
};
</script>

<style scoped lang="less">
.content-width-min {
  min-width: 1200px;
}
.active-container.extend {
  overflow: visible;
  .content {
    box-shadow: 0 0 4px 2px #d6d6d6;
    .context {
      height: auto;
    }
  }
}
.active-container {
  height: 174px;
  position: relative;
  overflow: hidden;
  margin: 19px 0 10px;
  z-index: 1;
  box-sizing: border-box;
  .active-extend-toggle {
    position: absolute;
    left: 50%;
    bottom: 14px;
    -webkit-transform: translateX(-50%);
    transform: translateX(-50%);
    display: inline-block;
    color: #f93684;
    font-size: 14px;
    cursor: pointer;
  }
  .content {
    min-height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background-image: url(https://rs.dance365.com/speacial-zone_6.png);
    background-size: 100% auto;
    background-repeat: no-repeat;
    background-position: top;
    border-radius: 4px;
    background-color: #fff;
    padding: 32px 35px;
    box-sizing: border-box;
    .title {
      font-size: 20px;
      font-weight: 700;
      color: #111;
    }
    .context {
      height: 68px;
      overflow: hidden;
      margin: 12px 0;
      font-size: 14px;
      line-height: 24px;
      white-space: pre-wrap;
      word-wrap: break-word;
    }
  }
}
// 类型
.filter-container.activity_zone {
  padding-bottom: 16px;
}
.filter-container {
  padding: 26px 30px;
  border-radius: 4px;
  background-color: #fff;
  margin-bottom: 10px;
  position: relative;
  .filter-content-container {
    overflow: hidden;
    .filter-row {
      font-size: 14px;
      .filter-label {
        color: #b1b5c1;
        padding: 7px 0;
        width: 8.33333%;
        float: left;
        box-sizing: border-box;
      }
      .filter-content {
        width: 91.66667%;
        float: left;
        box-sizing: border-box;
      }
      .select-item.active {
        background-color: #f93684;
        color: #fff;
      }
      .select-item {
        display: inline-block;
        cursor: pointer;
        font-size: 14px;
        border-radius: 4px;
        color: #7d8090;
        padding: 7px 13px;
        user-select: none;
        margin-right: 24px;
        margin-bottom: 10px;
      }
    }
  }
}
.el-row {
  position: relative;
  box-sizing: border-box;
}
</style>
